{layout name="layout" /}

<style>
    .table td a {
        text-decoration: none;
    }

    #search .select-box {
        display: inline;
    }

    #search .select-box select {
        border: none;
    }
</style>

<div class="Hui-article">
    <div class="pd-20" style="margin-left: 20px; min-width: 450px; max-width: 50%;">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a href="javascript:void(0);" class="btn btn-danger radius">
                    <i class="Hui-iconfont">&#xe6e2;</i>回收站</a>
            </span>
        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort">
                <thead>
                    <tr class="text-c">
                        <th width="40px">ID</th>
                        <th width="30%">文章标题</th>
                        <th width="150px">更新日期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {foreach $data as $val}
                    <tr class="text-c va-m">
                        <td>{$val.id}</td>
                        <td class="text-l">
                            <a href="javascript:;" style="text-decoration:none" title="浏览" onClick="layer_show('文章详情','{:url(\'/blog/preview\', \'id=\'.$val.id)}')">{$val.title}</a>
                        </td>
                        <td class="text-c">{$val.pubtime|date="Y-m-d H:i:s",###}</td>
                        <td class="td-manage">
                            <a href="javascript:;" title="恢复" style="text-decoration:none"
                                onClick="restore(this,'{$val.id}')">
                                <i class="Hui-iconfont">&#xe66b;</i>
                            </a>
                            <a href="javascript:;" title="彻底删除" style="text-decoration:none" class="ml-10"
                                onClick="real_del(this,'{$val.id}')">
                                <i class="Hui-iconfont">&#xe6e2;</i>
                            </a>
                        </td>
                    </tr>
                    {/foreach}
                </tbody>
            </table>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="r">
                {$data->render()}
            </span>
        </div>
    </div>
</div>

<!-- 请在下方写此页面业务相关的脚本 -->
<script type="text/javascript">
    function real_del(obj, id) {
        layer.confirm('从数据库中删除本条记录？', function (index) {
            $.post('realdel', {
                'id': id
            }, function (data) {
                if (data.code == 2) {
                    $(obj).parents("tr").remove();
                    layer.msg("操作成功!", {
                        icon: 6,
                        time: 2000
                    });
                    return false;
                } else {
                    layer.msg("操作失败, 请稍后重试!", {
                        icon: 5,
                        time: 2000
                    });
                    return false;
                }
            }, 'json');
        });
    }

    function restore(obj, id) {
        $.post('restore', {
                'id': id
        }, function (data) {
            if (data.code == 2) {
                $(obj).parents("tr").remove();
                layer.msg("操作成功!", {
                    icon: 6,
                    time: 2000
                });
                return false;
            } else {
                layer.msg("操作失败, 请稍后重试!", {
                    icon: 5,
                    time: 2000
                });
                return false;
            }
        }, 'json');
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->